package nl.ceasaro.poker.texasHoldEm.odds.mvc;

import nl.ceasaro.jeubelix.mvc.AbstractJeubelixController;
import nl.ceasaro.poker.texasHoldEm.game.mvc.TexasPokerCmd;
import nl.ceasaro.poker.texasHoldEm.odds.TexasOddsManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by IntelliJ IDEA.
 * User: cees
 * Date: Apr 13, 2007
 * Time: 8:21:01 PM
 *
 * @todo Document this class
 */
public class TexasOddsController extends AbstractJeubelixController
{
   Log log = LogFactory.getLog(TexasOddsController.class);
   private TexasOddsManager texasOddsManager;

   /**
    * @param httpServletRequest the HTTP request
    * @return a {@link nl.ceasaro.poker.texasHoldEm.game.TexasTable} command object.
    * @throws Exception
    */
   protected Object formBackingObject(HttpServletRequest httpServletRequest) throws Exception
   {
      return TexasPokerCmd.class;
   }

   protected ModelAndView showJeubelixForm(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, BindException bindException) throws Exception
   {
      ModelAndView view = new ModelAndView("texas.odds");
      view.addObject(getTexasOddsManager().getStandardDeck());
      return view;
   }

   protected ModelAndView processJeubelixForm(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object object, BindException bindException) throws Exception
   {
      String action = httpServletRequest.getParameter("action");
      if ("addCard".equals(action))
      {
         //getTexasGameManager().playRound();
      }
      ModelAndView view = new ModelAndView("texas.table");
      //view.addObject(getTexasOddsManager().getOdds());
      return view;
   }


   public TexasOddsManager getTexasOddsManager()
   {
      return texasOddsManager;
   }

   public void setTexasOddsManager(TexasOddsManager texasOddsManager)
   {
      this.texasOddsManager = texasOddsManager;
   }
}
